import { request } from "@/utils/request.js"

/**
 * 数据集 API接口
 */
export default {
  /**
   * 数据列表
   * @returns
   */
  getPageList(params = {}) {
    return request({
      url: "/datasource/DataCube/index",
      method: "get",
      params
    })
  },

  /**
   * 回收站数据列表
   * @returns
   */
  getRecyclePageList(params = {}) {
    return request({
      url: "/datasource/DataCube/recycle",
      method: "get",
      params
    })
  },

  /**
   * 添加数据
   * @returns
   */
  save(params = {}) {
    return request({
      url: "/datasource/DataCube/save",
      method: "post",
      data: params
    })
  },

  /**
   * 读取数据
   * @returns
   */
  read(id) {
    return request({
      url: "/datasource/DataCube/read?id=" + id,
      method: "get"
    })
  },

  /**
   * 软删除数据
   * @returns
   */
  delete(data) {
    return request({
      url: "/datasource/DataCube/destroy",
      method: "delete",
      data
    })
  },

  /**
   * 恢复回收站数据
   * @returns
   */
  recovery(data) {
    return request({
      url: "/datasource/DataCube/recovery",
      method: "post",
      data
    })
  },

  /**
   * 真实删除数据
   * @returns
   */
  realDestroy(data) {
    return request({
      url: "/datasource/DataCube/realDestroy",
      method: "delete",
      data
    })
  },

  /**
   * 更新数据
   * @returns
   */
  update(id, data = {}) {
    return request({
      url: "/datasource/DataCube/update?id=" + id,
      method: "put",
      data
    })
  },

  /**
   * 更改状态
   * @returns
   */
  changeStatus(data = {}) {
    return request({
      url: "/datasource/DataCube/changeStatus",
      method: "post",
      data
    })
  },

  getModelSchema(data = {}) {
    return request({})
  },

  refreshData(data = {}) {
    return request({
      url: "/datasource/DataCube/preview",
      method: "post",
      data
    })
  },

  dataCubeComponentPreview(data = {}) {
    return request({
      url: "/datasource/DataCube/previewComponent",
      method: "post",
      data
    })
  },

  dataCubeEnum(data) {
    return request({
      url: "/datasource/datacube/getEnum",
      method: "post",
      data
    })
  },

  dataCubeEnumList(data = {}) {
    return request({
      url: "/datasource/DataCube/enumList",
      method: "post",
      data
    })
  },

  // 保存枚举
  dataCubeSaveEnum(data) {
    return request({
      url: "/datasource/datacube/saveEnum",
      method: "post",
      data
    })
  },

  categoryTree() {
    return request({
      url: "/datasource/DataCubeCategory/index?tree=true",
      method: "get"
    })
  }
}
